import { BaseResponse, CustomAxiosRequestConfig } from '@/type/api'
import instance from './index'
/**
 * 获取问题
 */
export const getSessionList = (data = {}): Promise<BaseResponse> => {
  const config: CustomAxiosRequestConfig = { params: data, port: 9001 }
  return instance.get('/java/api/v1/chat/userid', config)
}

/**
 * 更新历史列表
 */
export const updateHistoryList = (data = {}, id: number | string) => {
  const config: CustomAxiosRequestConfig = { url: '/java/api/v1/chat/' + id, data: data, method: 'PUT', port: 9001 }
  return instance.request(config)
}

/**
 * 添加会话
 */
export const add = (userId: number) => {
  const config = { url: '/java/api/v1/chat/' + userId, method: 'POST', port: 9001 }
  return instance.request(config)
}

/**
 * 删除会话
 */
export const del = (id: number | string) => {
  const config = { url: '/java/api/v1/chat/' + id, method: 'delete', port: 9001 }
  return instance.request(config)
}

/**
 * 给后台 一次刷新列表的机会
 */
export const getHistoryToBackstage = (id: number | string) => {
  const config = { url: '/java/api/v1/chat/' + id, method: 'get', port: 9001 }
  return instance.request(config)
}
